﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Wise.Entities
{
    public class 表的列
    {
        public string 字段 { get; set; }

        public string 类型 { get; set; }

        public bool _IsGuid()
        {
            return 类型 == "uniqueidentifier";
        }

        static List<String> _Array_Of_String = new List<string>() { "char", "nchar", "varchar", "nvarchar", "text", "ntext" };

        public bool _IsString()
        {
            return _Array_Of_String.Contains(类型);
        }
        static List<String> _Array_Of_Numbers = new List<string>() { "bit", "tinyint", "int", "bigint", "numeric", "decimal", "float", "real", "smallmoney", "money" };

        public bool _IsNumber()
        {
            return _Array_Of_Numbers.Contains(类型);
        }
        static List<String> _Array_Of_DateTime = new List<string>() { "datetime", "datetime2", "date", "datetimeoffset",  };
        public bool _IsDateTime()
        {
            return _Array_Of_DateTime.Contains(类型);
        }

        public bool _IsTimeStamp()
        {
            return 类型 == "timestamp";
        }
      
        public bool _IsNeedScalar()
        {
            return 类型 == "decimal" || 类型 == "numeric";
        }
        static List<String> _Array_Of_Buffers = new List<string>() { "varbinary", "binary", "image" };

        public bool _IsBuffer()
        {
            return _Array_Of_Buffers.Contains(类型);
        }
        static List<String> _Array_Of_NeedLengths = new List<string>() {"char", "nchar", "varchar", "nvarchar", "datetime2", "datetimeoffset", "binary", "time", "varbinary" };
        internal bool _IsNeedLength()
        {
            return _Array_Of_NeedLengths.Contains(类型);
        }

        public int? 长度 { get; set; }
        public int? 精度 { get; set; }
        public bool 可空 { get; set; }
        public bool 标识规范 { get; set; }
        public int? 标识种子 { get; set; }
        public int? 标识增量 { get; set; }

        public override string ToString()
        {
            return $"{字段} {类型}";
        }
    }
}
